import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 菜谱信息 */
export interface Recipes {
  id: number // 主键ID
  recipeId: string // 菜谱ID
  recipeName?: string // 菜谱名称
  recipeTypeId: number // 菜谱分类ID
  foods: string // 食材
  description: string // 描述
  sort?: number // 排序
  status?: number // 状态
}

// 菜谱 API
export const RecipesApi = {
  // 查询菜谱分页
  getRecipesPage: async (params: any) => {
    return await request.get({ url: `/school/recipes/page`, params })
  },
  // 根据分类查询精简版食物
  getRecipeFoodList: async (foodTypeId: number) => {
    return await request.get({ url: `/school/recipe-food/simple-list?foodTypeId=` + foodTypeId })
  },
  // 根据菜谱分类查询菜谱列表
  getRecipesList: async (recipeTypeId: number) => {
    return await request.get({ url: `/school/recipes/simple-list?recipeTypeId=${recipeTypeId}` })
  },
  // 查询菜谱详情
  getRecipes: async (id: number) => {
    return await request.get({ url: `/school/recipes/get?id=` + id })
  },

  // 新增菜谱
  createRecipes: async (data: Recipes) => {
    return await request.post({ url: `/school/recipes/create`, data })
  },

  // 修改菜谱
  updateRecipes: async (data: Recipes) => {
    return await request.put({ url: `/school/recipes/update`, data })
  },

  // 删除菜谱
  deleteRecipes: async (id: number) => {
    return await request.delete({ url: `/school/recipes/delete?id=` + id })
  },

  /** 批量删除菜谱 */
  deleteRecipesList: async (ids: number[]) => {
    return await request.delete({ url: `/school/recipes/delete-list?ids=${ids.join(',')}` })
  },

  // 导出菜谱 Excel
  exportRecipes: async (params) => {
    return await request.download({ url: `/school/recipes/export-excel`, params })
  }
}
